#------------------------------------------------------------------------------#
#                                                                              #
#                               CHAPTER FOUR                                   #
#      Party politics amid civil war: Brutality, narcotrafficking and          #
#                  corruption in Colombia's transition                         #
#                                                                              #
#               Supplementary material: Panel Data R-syntax                    #
#                                                                              #
#                                   2022                                       #
#                                                                              #
#------------------------------------------------------------------------------#
# Data files #
directory <- "C:/FINAL.xlsx"
#Packages
library(stargazer)
library(plm)
library(dplyr)
library(tidyverse)
# Create the sub-levels
# 1. Mayors data set elections
City_Hall<-filter(Execute_elec_2010s, Election == "City Hall")
stargazer(as.data.frame(City_Hall), type="text", title = "Table1: Summary Statistics Mayor", out = "Table1 Summary Statistics Mayors.csv")
# 2. Governors data set elections
Governors<-filter(Execute_elec_2010s, Election == "Governor")
stargazer(as.data.frame(Governors), type="text", title = "Table2: Summary Statistics Governor", out = "Table2 Summary Statistics Governor.csv")
#3. Presidential data set elections
President<-filter(Execute_elec_2010s, Election == "President")
stargazer(as.data.frame(President), type="text", title = "Table3 Summary Statistics President", out = "Table3 Summary Statistics President.csv")
#------------------------Governor parties elected------------------------------#
Coca_Gov<-Governors$Coca.crops
Brutal_Gov<-Governors$Brutal.Ind
Corrup_Gov<-Governors$Corrupt.Ind
MIO_Gov<-Governors$MIO
Afrovides_Gov<-Governors$Afrovides
Comunes_Gov<-Governors$Comunes
MIRA_Gov<-Governors$MIRA
ADA_Gov<-Governors$`Partido Ada`
Humana_Gov<-Governors$`Colombia Humana`
Justa_Gov<-Governors$`Justa Libres`
Polo_Gov<-Governors$`Polo Dem Alt`
Union_Gov<-Governors$`Uni�n Pat`
GSC_Gov<-Governors$GSC
De_la_U_Gov<-Governors$`P. de la U`
C_Democrat_Gov<-Governors$`C. Democr�tico`
O_Ciudada_Gov<-Governors$Ciudadana
MAIS_Gov<-Governors$MAIS
Conservat_Gov<-Governors$Conservative
Liberal_Gov<-Governors$Liberal
ASI_Gov<-Governors$ASI
Radical_Gov<-Governors$Radical
Verde_Gov<-Governors$Verde
AICO_Gov<-Governors$AICO
Muni_Code_Gov<-Governors$MPIO_CCNCT
Quad_Gov<-Governors$Election
Vot_Turn_Gov<-Governors$`Voters turnout`
Paras_Gov<-Governors$AU_Pr
ELN_Gov<-Governors$ELN_Pr
FARC_Gov<-Governors$FARC_Pr
Fraud_Gov<-Governors$Elec_Fraud
#--------------------------Governor parties in office--------------------------# 
GovernorsWon<-filter(Governors, WON == "1")
#
Coca_GovW<-GovernorsWon$Coca.crops
Brutal_GovW<-GovernorsWon$Brutal.Ind
Corrup_GovW<-GovernorsWon$Corrupt.Ind
MIO_GovW<-GovernorsWon$MIO
Afrovides_GovW<-GovernorsWon$Afrovides
Comunes_GovW<-GovernorsWon$Comunes
MIRA_GovW<-GovernorsWon$MIRA
ADA_GovW<-GovernorsWon$`Partido Ada`
Humana_GovW<-GovernorsWon$`Colombia Humana`
Justa_GovW<-GovernorsWon$`Justa Libres`
Polo_GovW<-GovernorsWon$`Polo Dem Alt`
Union_GovW<-GovernorsWon$`Uni�n Pat`
GSC_GovW<-GovernorsWon$GSC
De_la_U_GovW<-GovernorsWon$`P. de la U`
C_Democrat_GovW<-GovernorsWon$`C. Democr�tico`
O_Ciudada_GovW<-GovernorsWon$Ciudadana
MAIS_GovW<-GovernorsWon$MAIS
Conservat_GovW<-GovernorsWon$Conservative
Liberal_GovW<-GovernorsWon$Liberal
ASI_GovW<-GovernorsWon$ASI
Radical_GovW<-GovernorsWon$Radical
Verde_GovW<-GovernorsWon$Verde
AICO_GovW<-GovernorsWon$AICO
Muni_Code_GovW<-GovernorsWon$MPIO_CCNCT
Quad_GovW<-GovernorsWon$Election
Vot_Turn_GovW<-GovernorsWon$`Voters turnout`
Paras_GovW<-GovernorsWon$AU_Pr
ELN_GovW<-GovernorsWon$ELN_Pr
FARC_GovW<-GovernorsWon$FARC_Pr
Fraud_GovW<-GovernorsWon$Elec_Fraud
#------------------------Governor parties in opposition------------------------#
GovernorsL<-filter(Governors, WON == "0")
#
Coca_GovL<-GovernorsL$Coca.crops
Brutal_GovL<-GovernorsL$Brutal.Ind
Corrup_GovL<-GovernorsL$Corrupt.Ind
MIO_GovL<-GovernorsL$MIO
Afrovides_GovL<-GovernorsL$Afrovides
Comunes_GovL<-GovernorsL$Comunes
MIRA_GovL<-GovernorsL$MIRA
ADA_GovL<-GovernorsL$`Partido Ada`
Humana_GovL<-GovernorsL$`Colombia Humana`
Justa_GovL<-GovernorsL$`Justa Libres`
Polo_GovL<-GovernorsL$`Polo Dem Alt`
Union_GovL<-GovernorsL$`Uni�n Pat`
GSC_GovL<-GovernorsL$GSC
De_la_U_GovL<-GovernorsL$`P. de la U`
C_Democrat_GovL<-GovernorsL$`C. Democr�tico`
O_Ciudada_GovL<-GovernorsL$Ciudadana
MAIS_GovL<-GovernorsL$MAIS
Conservat_GovL<-GovernorsL$Conservative
Liberal_GovL<-GovernorsL$Liberal
ASI_GovL<-GovernorsL$ASI
Radical_GovL<-GovernorsL$Radical
Verde_GovL<-GovernorsL$Verde
AICO_GovL<-GovernorsL$AICO
Muni_Code_GovL<-GovernorsL$MPIO_CCNCT
Quad_GovL<-GovernorsL$Election
Vot_Turn_GovL<-GovernorsL$`Voters turnout`
Paras_GovL<-GovernorsL$AU_Pr
ELN_GovL<-GovernorsL$ELN_Pr
FARC_GovL<-GovernorsL$FARC_Pr
Fraud_GovL<-GovernorsL$Elec_Fraud
#---------------------Table A1 Pooled OLS Models Estimator---------------------#
#
CocaGov_ols <- plm(formula = Coca_Gov ~ MIO_Gov + Afrovides_Gov + Comunes_Gov + MIRA_Gov + 
                      ADA_Gov + Humana_Gov + Justa_Gov + Polo_Gov + Union_Gov + GSC_Gov + 
                      De_la_U_Gov + C_Democrat_Gov + O_Ciudada_Gov + MAIS_Gov + Conservat_Gov
                    + Liberal_Gov + Radical_Gov + ASI_Gov + Verde_Gov + AICO_Gov + Vot_Turn_Gov +
                      Paras_Gov + ELN_Gov + FARC_Gov + Fraud_Gov, 
                    data = Governors, model = "pooling", 
                    index = c("MPIO_CCNCT", "Period"))
BrutalGov_ols <- plm(formula = Brutal_Gov ~ MIO_Gov + Afrovides_Gov + Comunes_Gov + MIRA_Gov + 
                     ADA_Gov + Humana_Gov + Justa_Gov + Polo_Gov + Union_Gov + GSC_Gov + 
                     De_la_U_Gov + C_Democrat_Gov + O_Ciudada_Gov + MAIS_Gov + Conservat_Gov
                   + Liberal_Gov + Radical_Gov + ASI_Gov + Verde_Gov + AICO_Gov + Vot_Turn_Gov +
                     Paras_Gov + ELN_Gov + FARC_Gov + Fraud_Gov, 
                   data = Governors, model = "pooling", 
                   index = c("MPIO_CCNCT", "Period")) 
CorrupGov_ols <- plm(formula = Corrup_Gov ~ MIO_Gov + Afrovides_Gov + Comunes_Gov + MIRA_Gov + 
                       ADA_Gov + Humana_Gov + Justa_Gov + Polo_Gov + Union_Gov + GSC_Gov + 
                       De_la_U_Gov + C_Democrat_Gov + O_Ciudada_Gov + MAIS_Gov + Conservat_Gov
                     + Liberal_Gov + Radical_Gov + ASI_Gov + Verde_Gov + AICO_Gov + Vot_Turn_Gov +
                       Paras_Gov + ELN_Gov + FARC_Gov + Fraud_Gov, 
                     data = Governors, model = "pooling", 
                     index = c("MPIO_CCNCT", "Period"))
#
CocaGovW_ols <- plm(formula = Coca_GovW ~ MIO_GovW + Afrovides_GovW + Comunes_GovW + MIRA_GovW + 
                        ADA_GovW + Humana_GovW + Justa_GovW + Polo_GovW + Union_GovW + GSC_GovW + 
                        De_la_U_GovW + C_Democrat_GovW + O_Ciudada_GovW + MAIS_GovW + Conservat_GovW
                      + Liberal_GovW + Radical_GovW + ASI_GovW + Verde_GovW + AICO_GovW + Vot_Turn_GovW +
                        Paras_GovW + ELN_GovW + FARC_GovW + Fraud_GovW, 
                      data = GovernorsWon, model = "pooling", 
                      index = c("MPIO_CCNCT", "Period"))  
BrutalGovW_ols <- plm(formula = Brutal_GovW ~ MIO_GovW + Afrovides_GovW + Comunes_GovW + MIRA_GovW + 
                        ADA_GovW + Humana_GovW + Justa_GovW + Polo_GovW + Union_GovW + GSC_GovW + 
                        De_la_U_GovW + C_Democrat_GovW + O_Ciudada_GovW + MAIS_GovW + Conservat_GovW
                      + Liberal_GovW + Radical_GovW + ASI_GovW + Verde_GovW + AICO_GovW + Vot_Turn_GovW +
                        Paras_GovW + ELN_GovW + FARC_GovW + Fraud_GovW, 
                      data = GovernorsWon, model = "pooling", 
                      index = c("MPIO_CCNCT", "Period"))
CorrupGovW_ols <- plm(formula = Corrup_GovW ~ MIO_GovW + Afrovides_GovW + Comunes_GovW + MIRA_GovW + 
                      ADA_GovW + Humana_GovW + Justa_GovW + Polo_GovW + Union_GovW + GSC_GovW + 
                      De_la_U_GovW + C_Democrat_GovW + O_Ciudada_GovW + MAIS_GovW + Conservat_GovW
                    + Liberal_GovW + Radical_GovW + ASI_GovW + Verde_GovW + AICO_GovW + Vot_Turn_GovW +
                      Paras_GovW + ELN_GovW + FARC_GovW + Fraud_GovW, 
                    data = GovernorsWon, model = "pooling", 
                    index = c("MPIO_CCNCT", "Period"))
#
CocaGovL_ols <- plm(formula = Coca_GovL ~ MIO_GovL + Afrovides_GovL + Comunes_GovL + MIRA_GovL + 
                      ADA_GovL + Humana_GovL + Justa_GovL + Polo_GovL + Union_GovL + GSC_GovL + 
                      De_la_U_GovL + C_Democrat_GovL + O_Ciudada_GovL + MAIS_GovL + Conservat_GovL
                    + Liberal_GovL + Radical_GovL + ASI_GovL + Verde_GovL + AICO_GovL + Vot_Turn_GovL
                    + Paras_GovL + ELN_GovL + FARC_GovL + Fraud_GovL, 
                    data = GovernorsWon, model = "pooling", 
                    index = c("MPIO_CCNCT", "Period")) 
#
BrutalGovL_ols <- plm(formula = Brutal_GovL ~ MIO_GovL + Afrovides_GovL + Comunes_GovL + MIRA_GovL + 
                       ADA_GovL + Humana_GovL + Justa_GovL + Polo_GovL + Union_GovL + GSC_GovL + 
                       De_la_U_GovL + C_Democrat_GovL + O_Ciudada_GovL + MAIS_GovL + Conservat_GovL
                     + Liberal_GovL + Radical_GovL + ASI_GovL + Verde_GovL + AICO_GovL + Vot_Turn_GovL
                     + Paras_GovL + ELN_GovL + FARC_GovL + Fraud_GovL, 
                     data = GovernorsWon, model = "pooling", 
                     index = c("MPIO_CCNCT", "Period"))
#
CorrupGovL_ols <- plm(formula = Corrup_GovL ~ MIO_GovL + Afrovides_GovL + Comunes_GovL + MIRA_GovL + 
                       ADA_GovL + Humana_GovL + Justa_GovL + Polo_GovL + Union_GovL + GSC_GovL + 
                       De_la_U_GovL + C_Democrat_GovL + O_Ciudada_GovL + MAIS_GovL + Conservat_GovL
                     + Liberal_GovL + Radical_GovL + ASI_GovL + Verde_GovL + AICO_GovL + Vot_Turn_GovL
                     + Paras_GovL + ELN_GovL + FARC_GovL + Fraud_GovL, 
                     data = GovernorsWon, model = "pooling", 
                     index = c("MPIO_CCNCT", "Period"))
#
stargazer(CocaGov_ols, BrutalGov_ols, CorrupGov_ols,
          CocaGovW_ols, BrutalGovW_ols, CorrupGovW_ols, CocaGovL_ols, 
          BrutalGovL_ols, CorrupGovL_ols,type = "text", 
          title = "Table4: Pooled OLS Models Governors", out = "Table4_Pooles_OLS.csv")
#
#-------------- Table A2 Fixed Effects within estimator------------------------#
#
FECoca_Gov <- update(CocaGov_ols, model="within", effect= "individual")
FEBrutal_Gov <- update(BrutalGov_ols, model="within", effect= "individual")
FECorrup_Gov <- update(CorrupGov_ols, model="within", effect= "individual")
FECoca_GovW <- update(CocaGovW_ols, model="within", effect= "individual")
FEBrutal_GovW <- update(BrutalGovW_ols, model="within", effect= "individual")
FECorrup_GovW <- update(CorrupGovW_ols, model="within", effect= "individual")
FECoca_GovL <- update(CocaGovL_ols, model="within", effect= "individual")
FEBrutal_GovL <- update(BrutalGovL_ols, model="within", effect= "individual")
FECorrup_GovL <- update(CorrupGovL_ols, model="within", effect= "individual")
stargazer(FECoca_Gov, type = "text", title = "FE_Coca-Gov", out = "FE_Coca-Gov.csv")
stargazer(FEBrutal_Gov, type = "text", title = "FE_Brutal-Gov", out = "FE_Brutal-Gov.csv")
stargazer(FECoca_Gov, FEBrutal_Gov, FECorrup_Gov, FECoca_GovW, FEBrutal_GovW, FECorrup_GovW, FECoca_GovL, FEBrutal_GovL,
          FECorrup_GovL, type = "text", title = "Table7: Fixed Effects Governors", out = "Table 7_Fixed Effects Governors.txt")
#
#-----Table A3 Least square dummy variables regression with fixed effects------#
#
CocaGov_DV <- update (CocaGov_ols, ~ . + factor(Muni_Code_Gov))
BrutalGov_DV <- update (BrutalGov_ols, ~ . + factor(Muni_Code_Gov))
CorrupGov_DV <- update (CorrupGov_ols, ~ . + factor(Muni_Code_Gov))
CocaGovW_DV <- update (CocaGovW_ols, ~ . + factor(Muni_Code_GovW))
BrutalGovW_DV <- update (BrutalGovW_ols, ~ . + factor(Muni_Code_GovW))
CorrupGovW_DV <- update (CorrupGovW_ols, ~ . + factor(Muni_Code_GovW))
CocaGovL_DV <- update (CocaGovL_ols, ~ . + factor(Muni_Code_GovL))
BrutalGovL_DV <- update (BrutalGovL_ols, ~ . + factor(Muni_Code_GovL))
CorrupGovL_DV <- update (CorrupGovL_ols, ~ . + factor(Muni_Code_GovL))
# 
summary(CocaGov_DV)
yhat <- fitted(CocaGov_DV)
y <- pmodel.response(CocaGov_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FECoca_Gov)^2))
(rsquared <- mss / (mss + ess))
#
summary(BrutalGov_DV)
yhat <- fitted(BrutalGov_DV)
y <- pmodel.response(BrutalGov_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FEBrutal_Gov)^2))
(rsquared <- mss / (mss + ess))
#
summary(CorrupGov_DV)
yhat <- fitted(CorrupGov_DV)
y <- pmodel.response(CorrupGov_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FECorrup_Gov)^2))
(rsquared <- mss / (mss + ess))
#
summary(CocaGovW_DV)
yhat <- fitted(CocaGovW_DV)
y <- pmodel.response(CocaGovW_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FECoca_GovW)^2))
(rsquared <- mss / (mss + ess))
#
summary(BrutalGovW_DV)
yhat <- fitted(BrutalGovW_DV)
y <- pmodel.response(BrutalGovW_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FEBrutal_GovW)^2))
(rsquared <- mss / (mss + ess))
#
summary(CorrupGovW_DV)
yhat <- fitted(CorrupGovW_DV)
y <- pmodel.response(CorrupGovW_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FECorrup_GovW)^2))
(rsquared <- mss / (mss + ess))
#
summary(CocaGovL_DV)
yhat <- fitted(CocaGovL_DV)
y <- pmodel.response(CocaGovL_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FECoca_GovL)^2))
(rsquared <- mss / (mss + ess))
#
summary(BrutalGovL_DV)
yhat <- fitted(BrutalGovL_DV)
y <- pmodel.response(BrutalGovL_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FEBrutal_GovL)^2))
(rsquared <- mss / (mss + ess))
#
summary(CorrupGovL_DV)
yhat <- fitted(CorrupGovL_DV)
y <- pmodel.response(CorrupGovL_DV)
(mss <- sum((yhat - mean(y))^2))
(ess <- sum(resid(FECorrup_GovL)^2))
(rsquared <- mss / (mss + ess))
#
# Random effects estimator ------------------------------------------------
# Random effects estimator (Singular matrix and cannot be inverted, some vectors are collinear)
CocaGov_RE <- update (CocaGov_ols, model = "random", random.method = "walhus")
BrutalGov_RE <- update (BrutalGov_ols, model = "random", random.method = "walhus")
CorrupGov_RE <- update (CorrupGov_ols, model = "random", random.method = "walhus")
CocaGovW_RE <- update (CocaGovW_ols, model = "random", random.method = "walhus")
BrutalGovW_RE <- update (BrutalGovW_ols, model = "random", random.method = "walhus")
CorrupGovW_RE <- update (CorrupGovW_ols, model = "random", random.method = "walhus")
CocaGovL_RE <- update (CocaGovL_ols, model = "random", random.method = "walhus")
BrutalGovL_RE <- update (BrutalGovL_ols, model = "random", random.method = "walhus")
CorrupGovL_RE <- update (CorrupGovL_ols, model = "random", random.method = "walhus")
#
#------------------------President parties elected------------------------------#
#There is a homogeneity issue because the results in 2014 and 2018 are the opposite #
Coca_Pres<-President$Coca.crops
Brutal_Pres<-President$Brutal.Ind
Corrup_Pres<-President$Corrupt.Ind
MIO_Pres<-President$MIO
Afrovides_Pres<-President$Afrovides
Comunes_Pres<-President$Comunes
MIRA_Pres<-President$MIRA
ADA_Pres<-President$`Partido Ada`
Humana_Pres<-President$`Colombia Humana`
Justa_Pres<-President$`Justa Libres`
Polo_Pres<-President$`Polo Dem Alt`
Union_Pres<-President$`Uni�n Pat`
GSC_Pres<-President$GSC
De_la_U_Pres<-President$`P. de la U`
C_Democrat_Pres<-President$`C. Democr�tico`
O_Ciudada_Pres<-President$Ciudadana
MAIS_Pres<-President$MAIS
Conservat_Pres<-President$Conservative
Liberal_Pres<-President$Liberal
ASI_Pres<-President$ASI
Radical_Pres<-President$Radical
Verde_Pres<-President$Verde
AICO_Pres<-President$AICO
Muni_Code_Pres<-President$MPIO_CCNCT
Quad_Pres<-President$Election
Vot_Turn_Pres<-President$`Voters turnout`
Paras_Pres<-President$AU_Pr
ELN_Pres<-President$ELN_Pr
FARC_Pres<-President$FARC_Pr
Fraud_Pres<-President$Elec_Fraud
#--------------------------President parties in office--------------------------# 
PresidentWon<-filter(President, WON == "1")
Coca_PresW<-PresidentWon$Coca.crops
Brutal_PresW<-PresidentWon$Brutal.Ind
Corrup_PresW<-PresidentWon$Corrupt.Ind
MIO_PresW<-PresidentWon$MIO
Afrovides_PresW<-PresidentWon$Afrovides
Comunes_PresW<-PresidentWon$Comunes
MIRA_PresW<-PresidentWon$MIRA
ADA_PresW<-PresidentWon$`Partido Ada`
Humana_PresW<-PresidentWon$`Colombia Humana`
Justa_PresW<-PresidentWon$`Justa Libres`
Polo_PresW<-PresidentWon$`Polo Dem Alt`
Union_PresW<-PresidentWon$`Uni�n Pat`
GSC_PresW<-PresidentWon$GSC
De_la_U_PresW<-PresidentWon$`P. de la U`
C_Democrat_PresW<-PresidentWon$`C. Democr�tico`
O_Ciudada_PresW<-PresidentWon$Ciudadana
MAIS_PresW<-PresidentWon$MAIS
Conservat_PresW<-PresidentWon$Conservative
Liberal_PresW<-PresidentWon$Liberal
ASI_PresW<-PresidentWon$ASI
Radical_PresW<-PresidentWon$Radical
Verde_PresW<-PresidentWon$Verde
AICO_PresW<-PresidentWon$AICO
Muni_Code_PresW<-PresidentWon$MPIO_CCNCT
Quad_PresW<-PresidentWon$Election
Vot_Turn_PresW<-PresidentWon$`Voters turnout`
Paras_PresW<-PresidentWon$AU_Pr
ELN_PresW<-PresidentWon$ELN_Pr
FARC_PresW<-PresidentWon$FARC_Pr
Fraud_PresW<-PresidentWon$Elec_Fraud
#----------------------President parties in opposition-------------------------# 
PresidentL<-filter(President, WON == "0")
Coca_PresL<-PresidentL$Coca.crops
Brutal_PresL<-PresidentL$Brutal.Ind
Corrup_PresL<-PresidentL$Corrupt.Ind
MIO_PresL<-PresidentL$MIO
Afrovides_PresL<-PresidentL$Afrovides
Comunes_PresL<-PresidentL$Comunes
MIRA_PresL<-PresidentL$MIRA
ADA_PresL<-PresidentL$`Partido Ada`
Humana_PresL<-PresidentL$`Colombia Humana`
Justa_PresL<-PresidentL$`Justa Libres`
Polo_PresL<-PresidentL$`Polo Dem Alt`
Union_PresL<-PresidentL$`Uni�n Pat`
GSC_PresL<-PresidentL$GSC
De_la_U_PresL<-PresidentL$`P. de la U`
C_Democrat_PresL<-PresidentL$`C. Democr�tico`
O_Ciudada_PresL<-PresidentL$Ciudadana
MAIS_PresL<-PresidentL$MAIS
Conservat_PresL<-PresidentL$Conservative
Liberal_PresL<-PresidentL$Liberal
ASI_PresL<-PresidentL$ASI
Radical_PresL<-PresidentL$Radical
Verde_PresL<-PresidentL$Verde
AICO_PresL<-PresidentL$AICO
Muni_Code_PresL<-PresidentL$MPIO_CCNCT
Quad_PresL<-PresidentL$Election
Vot_Turn_PresL<-PresidentL$`Voters turnout`
Paras_PresL<-PresidentL$AU_Pr
ELN_PresL<-PresidentL$ELN_Pr
FARC_PresL<-PresidentL$FARC_Pr
Fraud_PresL<-PresidentL$Elec_Fraud
#----------------------------Pooled OLS estimator------------------------------#
CocaPres_ols <- plm(formula = Coca_Pres ~ MIO_Pres + Afrovides_Pres + Comunes_Pres + MIRA_Pres + 
                     ADA_Pres + Humana_Pres + Justa_Pres + Polo_Pres + Union_Pres + GSC_Pres + 
                     De_la_U_Pres + C_Democrat_Pres + O_Ciudada_Pres + MAIS_Pres + Conservat_Pres
                   + Liberal_Pres + Radical_Pres + ASI_Pres + Verde_Pres + AICO_Pres + Vot_Turn_Pres +
                     Paras_Pres + ELN_Pres + FARC_Pres + Fraud_Pres, 
                   data = President, model = "pooling", 
                   index = c("MPIO_CCNCT", "Period"))
BrutalPres_ols <- plm(formula = Brutal_Pres ~ MIO_Pres + Afrovides_Pres + Comunes_Pres + MIRA_Pres + 
                      ADA_Pres + Humana_Pres + Justa_Pres + Polo_Pres + Union_Pres + GSC_Pres + 
                      De_la_U_Pres + C_Democrat_Pres + O_Ciudada_Pres + MAIS_Pres + Conservat_Pres
                    + Liberal_Pres + Radical_Pres + ASI_Pres + Verde_Pres + AICO_Pres + Vot_Turn_Pres +
                      Paras_Pres + ELN_Pres + FARC_Pres + Fraud_Pres, 
                    data = President, model = "pooling", 
                    index = c("MPIO_CCNCT", "Period"))
CorruptPres_ols <- plm(formula = Corrup_Pres ~ MIO_Pres + Afrovides_Pres + Comunes_Pres + MIRA_Pres + 
                        ADA_Pres + Humana_Pres + Justa_Pres + Polo_Pres + Union_Pres + GSC_Pres + 
                        De_la_U_Pres + C_Democrat_Pres + O_Ciudada_Pres + MAIS_Pres + Conservat_Pres
                      + Liberal_Pres + Radical_Pres + ASI_Pres + Verde_Pres + AICO_Pres + Vot_Turn_Pres +
                        Paras_Pres + ELN_Pres + FARC_Pres + Fraud_Pres, 
                      data = President, model = "pooling", 
                      index = c("MPIO_CCNCT", "Period"))
CocaPresW_ols <- plm(formula = Coca_PresW ~ MIO_PresW + Afrovides_PresW + Comunes_PresW + MIRA_PresW + 
                      ADA_PresW + Humana_PresW + Justa_PresW + Polo_PresW + Union_PresW + GSC_PresW + 
                      De_la_U_PresW + C_Democrat_PresW + O_Ciudada_PresW + MAIS_PresW + Conservat_PresW
                    + Liberal_PresW + Radical_PresW + ASI_PresW + Verde_PresW + AICO_PresW + Vot_Turn_PresW +
                      Paras_PresW + ELN_PresW + FARC_PresW + Fraud_PresW, 
                    data = President, model = "pooling", 
                    index = c("MPIO_CCNCT", "Period"))
BrutalPresW_ols <- plm(formula = Brutal_PresW ~ MIO_PresW + Afrovides_PresW + Comunes_PresW + MIRA_PresW + 
                         ADA_PresW + Humana_PresW + Justa_PresW + Polo_PresW + Union_PresW + GSC_PresW + 
                         De_la_U_PresW + C_Democrat_PresW + O_Ciudada_PresW + MAIS_PresW + Conservat_PresW
                       + Liberal_PresW + Radical_PresW + ASI_PresW + Verde_PresW + AICO_PresW + Vot_Turn_PresW +
                         Paras_PresW + ELN_PresW + FARC_PresW + Fraud_PresW, 
                       data = President, model = "pooling", 
                       index = c("MPIO_CCNCT", "Period"))
CorruptPresW_ols <- plm(formula = Corrup_PresW ~ MIO_PresW + Afrovides_PresW + Comunes_PresW + MIRA_PresW + 
                          ADA_PresW + Humana_PresW + Justa_PresW + Polo_PresW + Union_PresW + GSC_PresW + 
                          De_la_U_PresW + C_Democrat_PresW + O_Ciudada_PresW + MAIS_PresW + Conservat_PresW
                        + Liberal_PresW + Radical_PresW + ASI_PresW + Verde_PresW + AICO_PresW + Vot_Turn_PresW +
                          Paras_PresW + ELN_PresW + FARC_PresW + Fraud_PresW, 
                        data = President, model = "pooling", 
                        index = c("MPIO_CCNCT", "Period"))
CocaPresL_ols <- plm(formula = Coca_PresL ~ MIO_PresL + Afrovides_PresL + Comunes_PresL + MIRA_PresL + 
                       ADA_PresL + Humana_PresL + Justa_PresL + Polo_PresL + Union_PresL + GSC_PresL + 
                       De_la_U_PresL + C_Democrat_PresL + O_Ciudada_PresL + MAIS_PresL + Conservat_PresL
                     + Liberal_PresL + Radical_PresL + ASI_PresL + Verde_PresL + AICO_PresL + Vot_Turn_PresL +
                       Paras_PresL + ELN_PresL + FARC_PresL + Fraud_PresL, 
                     data = President, model = "pooling", 
                     index = c("MPIO_CCNCT", "Period"))
BrutalPresL_ols <- plm(formula = Brutal_PresL ~ MIO_PresL + Afrovides_PresL + Comunes_PresL + MIRA_PresL + 
                         ADA_PresL + Humana_PresL + Justa_PresL + Polo_PresL + Union_PresL + GSC_PresL + 
                         De_la_U_PresL + C_Democrat_PresL + O_Ciudada_PresL + MAIS_PresL + Conservat_PresL
                       + Liberal_PresL + Radical_PresL + ASI_PresL + Verde_PresL + AICO_PresL + Vot_Turn_PresL +
                         Paras_PresL + ELN_PresL + FARC_PresL + Fraud_PresL, 
                       data = President, model = "pooling", 
                       index = c("MPIO_CCNCT", "Period"))
CorruptPresL_ols <- plm(formula = Corrup_PresL ~ MIO_PresL + Afrovides_PresL + Comunes_PresL + MIRA_PresL + 
                          ADA_PresL + Humana_PresL + Justa_PresL + Polo_PresL + Union_PresL + GSC_PresL + 
                          De_la_U_PresL + C_Democrat_PresL + O_Ciudada_PresL + MAIS_PresL + Conservat_PresL
                        + Liberal_PresL + Radical_PresL + ASI_PresL + Verde_PresL + AICO_PresL + Vot_Turn_PresL +
                          Paras_PresL + ELN_PresL + FARC_PresL + Fraud_PresL, 
                        data = President, model = "pooling", 
                        index = c("MPIO_CCNCT", "Period"))
#
stargazer(CocaPres_ols, BrutalPres_ols, CorrupPres_ols,
          CocaPresW_ols, BrutalPresW_ols, CorrupPresW_ols, CocaPresL_ols, 
          BrutalPresL_ols, CorrupPresL_ols,type = "text", 
          title = "Table9: Pooled OLS Models Presidents", out = "Table9_Pooles_OLS_Presidents.csv")
#
#-------------- Table C2 Fixed Effects within estimator------------------------#
#
FECoca_Pres <- update(CocaPres_ols, model="within", effect= "individual")
FEBrutal_Pres <- update(BrutalPres_ols, model="within", effect= "individual")
FECorrup_Pres <- update(CorruptPres_ols, model="within", effect= "individual")
FECoca_PresW <- update(CocaPresW_ols, model="within", effect= "individual")
FEBrutal_PresW <- update(BrutalPresW_ols, model="within", effect= "individual")
FECorrup_PresW <- update(CorruptPresW_ols, model="within", effect= "individual")
FECoca_PresL <- update(CocaPresL_ols, model="within", effect= "individual")
FEBrutal_PresL <- update(BrutalPresL_ols, model="within", effect= "individual")
FECorrup_PresL <- update(CorruptPresL_ols, model="within", effect= "individual")
stargazer(FECoca_Pres, FEBrutal_Pres, FECorrup_Pres, FECoca_PresW, FEBrutal_PresW, FECorrup_PresW, FECoca_PresL, FEBrutal_PresL,
          FECorrup_PresL, type = "text", title = "Table10: Fixed Effects Presidential", out = "Table 7_Fixed Effects Presidential.csv")
#                                                                              #
#------------------------------- End of the script ----------------------------#































